<%--
  Created by IntelliJ IDEA.
  User: DongZhengWei
  Date: 2018/11/22
  Time: 10:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<style>
	#editLogo{
		position: absolute;
		margin:auto;
		top: 0;
		left: 0;
		width: 96px;
		height: 96px;
		padding-top: 40px;
		text-align: center;
		vertical-align:middle;
		background-color: rgba(0,0,0,0.3);
		color: #FFF;
		cursor: pointer;
		opacity: 0;
	}
	#editLogo:hover{
		opacity: 1;
	}
	#logoContainer{
		position: relative;
		width: 96px;
		height: 96px;
		margin: 0 auto;
		overflow: hidden;
	}
</style>

<div id="page-content">
	<div class="panel">
		<div class="panel-heading">
			<h3 class="panel-title">企业信息</h3>
		</div>
		<div class="panel-body">

			<form id="form_company" class="form-horizontal">
				<input type="hidden" id="keyId" name="keyId" value="${company.id}" />
				<input type="hidden" id="logoFileId" name="logoFileId" value="${company.logoFileId}" />

				<div class="form-group">
					<div class="col-md-6 col-md-offset-3 text-center">
						<div id="logoContainer" class="img-circle">
							<img id="companyLogoImg" alt="${company.name}" class="img-lg" src="${logoUrl}">
							<div id="editLogo">修改图片</div>
						</div>
					</div>
				</div>

				<div class="form-group">
					<label for="name" class="col-md-3 control-label">医院全称</label>
					<div class="col-md-6">
						<input type="text" placeholder="医院全称" class="form-control" id="name" name="name" value="${company.name}">
					</div>
				</div>

				<div class="form-group">
					<label for="name" class="col-md-3 control-label">医院简称</label>
					<div class="col-md-6">
						<input type="text" placeholder="医院简称" class="form-control" id="subName" name="subName" value="${company.subName}">
					</div>
				</div>

				<div class="form-group">
					<label for="place" class="col-md-3 control-label">医院地址</label>
					<div class="col-md-6" style="position: relative;">
						<input id="place" name="place" readonly type="text" data-toggle="city-picker" placeholder="点击从下拉面板中选择省/市/区">
					</div>
				</div>

				<div class="form-group">
					<label for="address" class="col-md-3 control-label">街道信息</label>
					<div class="col-md-6">
						<input type="text" placeholder="街道信息" class="form-control" id="address" name="address" value="${company.address}">
					</div>
				</div>

				<div class="form-group">
					<label for="description" class="col-md-3 control-label">医院描述</label>
					<div class="col-md-6">
						<input type="text" placeholder="医院描述" class="form-control" id="description" name="description" value="${company.description}">
					</div>
				</div>

			</form>
		</div>
		<div class="panel-footer">
			<button id="btn-company-save" class="btn btn-primary pull-right pli-data-upload" type="button"> 保存</button>
		</div>

	</div>
</div>

<script>

	//省市联动选择
    $("#place").citypicker({
        province : "${company.province}",
        city : "${company.city}",
        district : "${company.county}"
    });

    //点击修改logo
	$("#editLogo").click(function(){
	    __open_dialog_form("修改LOGO","<%=path%>/main/company/logoDialog?companyId=${company.id}",function(dialogRef){
			var callback = function(data){
			    if(data && data.state===1){
			        dialogRef.close();
			        $("#logoFileId").val(data.data.id);
			        $("#companyLogoImg").attr("src", "../main/file/download?keyId=" + data.data.id);
			    }else{
			        dialogRef.enableButtons();
			    }
			};
			fn_save_logo(callback);
		})
	});

	//保存
	$("#btn-company-save").click(function(){
        __btn_loading($(this));
        __form_save("form_company","<%=path%>/main/company/save",function(data){
            setTimeout(function(){
                __btn_reset($("#btn-company-save"));
            },500);
        })
	});


</script>